package com.yingside.io.io;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

public class TestProperties {
    public static void main(String[] args) {
        /*Properties pps = new Properties();
        try {
            pps.load(new FileReader("jdbc.properties"));

            String username = pps.getProperty("username");
            System.out.println("username = " + username);

            String password = pps.getProperty("password");
            System.out.println("password = " + password);

            // 只能讲pps对象内存中的值改变，并不能直接改变文件里面的内容
            pps.setProperty("username","王迪宁");


        } catch (IOException e) {
            e.printStackTrace();
        }*/

        Properties properties = System.getProperties();
        //properties.list(System.out);

        // 直接获取到项目的根路径
        String path = properties.get("user.dir").toString();
        System.out.println("path = " + path);

        File file = new File(properties.get("user.dir") + File.separator + "bb.txt");
        System.out.println("file.exists() = " + file.exists());


    }
}
